/* * legendary.js */ if ( typeof LD == "undefined" ) { var LD = {}; } if ( typeof $ == "undefined" || $ == null ) { var $ = jQuery; } /* Helper method for slugifying strings */ LD.slugify= function(string) { const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;' const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------' const p = new RegExp(a.split('').join('|'), 'g') return string.toString().toLowerCase() .replace(/\s+/g, '-') // Replace spaces with - .replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters .replace(/&/g, '-and-') // Replace & with 'and' .replace(/[^\w\-]+/g, '') // Remove all non-word characters .replace(/\-\-+/g, '-') // Replace multiple - with single - .replace(/^-+/, '') // Trim - from start of text .replace(/-+$/, '') // Trim - from end of text } /* Currently unused method for opening details from inside a standard listw widget */ LD.openDetails = function(node, basepg) { var recId = $(node).attr("rec-id"); var rNam = $(node).attr("rec-name"); window.location.href='/'+basepg+'/?/view/'+recId+'/'+LD.slugify(rNam); } /* init page method called inline from plugins to instantiate the page */ LD.initialized = typeof LD.initialized == "boolean" ? LD.initialized : false; LD.profileInitialized = typeof LD.profileInitialized == "boolean" ? LD.profileInitialized : false; LD.buildListLink = function(list, basepg) { let url = typeof list.URL == "string" && list.URL != null ? list.URL.toLowerCase() : ""; let itemId = typeof list.LISTID == "number" ? list.LISTID : "sf"+list.FILEID; return url.indexOf("http") == 0 ? url : '/'+basepg+'/'+itemId+'/'+LD.slugify( list.NAME ); } LD.bookmarkDownloader = null; LD.initPage = function() { if ( LD.initialized === true ) return; LD.initialized = true; var basepg = $('[ldl-basepg]').attr("ldl-basepg"); /* overrides the native MYTHYR method for refactoring internal links based on the list object -- this makes the links * internally consistent within the wordpress plugin */ $MYTHYR.buildListLink = function(list) { if ( typeof $MYTHYR.altBuildListLink == "function" ) return $MYTHYR.altBuildListLink( list ); return LD.buildListLink( list, basepg ); } $MYTHYR.widget.profileAnchor = "#ldl-bookmarks-anchor:not([anchor-disabled])"; if ( typeof LD.bookmarkDownloader == "object" && LD.bookmarkDownloader != null && typeof $MYTHYR.bookmarker != "undefined" ) { $MYTHYR.bookmarker.download = LD.bookmarkDownloader; } /* find all instances of attribute [ldl-list-id] and use as the basis for creating an interactive list on the page, using the native MYTHYR list * widget -- see constructor $MYTHYR.widget */ $( '[ldl-list-id]:not(.ignore-core-init)' ).each( function() { var node = $(this); var listId = node.attr( "ldl-list-id" ); var host = node.attr( "ldl-host" ); var views = node.attr("ldl-views"); var dsearch = node.attr( "ldl-dsearch" ) == "true"; var aViews = []; var allowedOpts = ["list","pie","series","map"]; if ( views != null && views.length > 0 ) { var ar = views.split( "," ); for ( var i=0; i 0 ) { cfg.q={key:qKey}; } var profilePg = node.attr( "ldl-profile-page" ); if ( typeof profilePg == "string" && profilePg.length > 0 ) { cfg.profilePath = "/"+profilePg+"/@@RECID@@/@@RECNAME@@"; let dBookmarker = (node.attr( "ldl-bookmarks-enabled" ) == "false"); cfg.disableBookmarker = dBookmarker; } $MYTHYR.widget("list",cfg); }); /* find all instances of attribute [ldl-estore] and use as the basis for creating an interactive e-store on the page, using the nativ * MYTHYR e-store widget -- see constructor $MYTHYR.estore */ $( '[ldl-estore]').each( function() { var node = $(this); var host = node.attr("ldl-host"); var cfg = {prefix:"ldldata", libHost:host}; var qKey = node.attr( "ldl-qkey"); cfg.esearch = true; cfg.staticFileDetails = true; if ( typeof qKey == "string" && qKey != null && qKey.length > 0 ) { cfg.q={key:qKey}; } cfg.ajaxMethod="POST"; cfg.host="/wp-admin/admin-ajax.php?action=ldl_relay&mode=estore&url="; $MYTHYR.estore(cfg); }); /* find all instances of attribute ldl-resolve and use as the basis for hyperlinking names of published businesses and executives found * within the body of a post on the page -- this is controlled in the admin tool under Enhanced ... */ $( '[ldl-resolve]').each( function() { var node = $(this); var libHost = node.attr("ldl-host"); var host = '/wp-admin/admin-ajax.php?action=ldl_relay&url='; var postId = node.attr( "ldl-postid" ); var ttl = node.attr("ldl-title"); var dt = node.attr( "ldl-date" ); var cfg = {prefix:"ldlresolve", host:host, libhost:libHost, pageId:postId, pageTitle:ttl, pageDt:dt, firstReferenceOnly:true }; $MYTHYR.resolve(cfg); }); } LD.initProfile = function() { if ( LD.profileInitialized === true ) return; LD.profileInitialized = true; var basepg = $('[ldl-basepg]').attr("ldl-basepg"); $MYTHYR.buildListLink = function(list) { if ( typeof $MYTHYR.altBuildListLink == "function" ) return $MYTHYR.altBuildListLink( list ); return LD.buildListLink( list, basepg ); } if ( typeof LD.bookmarkDownloader == "object" && LD.bookmarkDownloader != null && typeof $MYTHYR.bookmarker != "undefined" ) { $MYTHYR.bookmarker.download = LD.bookmarkDownloader; } $( '[ldl-rec-id]' ).each( function() { var node = $(this); var recId = node.attr( "ldl-rec-id" ); let guid = "ldl-profile-interface"; node.attr( "mythyr-widget-guid", guid ); let libhost = node.attr( "ldl-host" ); let host = '/wp-admin/admin-ajax.php?action=ldl_relay&url='; let profilePg = node.attr( "ldl-profile-page" ); let dBookmarker = (node.attr( "ldl-bookmarks-enabled" ) == "false"); let cfg = {guid:guid, host:host, libhost:libhost, prefix:"ldprofile", profileUrl:"/"+profilePg+"/@@RECID@@/@@RECNAME@@", disableBookmarker:dBookmarker}; let includeTimeline = node.attr( "ldl-timeline" ) == "true"; if ( includeTimeline ) { cfg.timelineAnchor = '#ldprofile-timeline'; } $MYTHYR.profile(recId, cfg); }); } LD.recentDocTemplate = '
@THUMBNAIL@

@TITLE@

'; LD.recentArticlesUI = function(recId, handle) { this.recId = recId; this.parentNode = $(handle); this.limit = LD.recentArticlesUI.limit; this.thumbAlias = LD.recentArticlesUI.thumbAlias; this.offset = 0; this.ele = $('
'); this.loadbtn = $('
More posts ...
'); this.apply = function( docs ) { for ( let i=0; i') ) .replace( /@DATE@/g, doc.post_date ) .replace( /@EXCERPT@/g, doc.post_excerpt ) .replace( /@AUTHORDISPLAY@/g, doc.post_author.display_name ) .replace( /@AUTHORNICE@/g, doc.post_author.user_nicename ); this.ele.append( htm ); } if ( docs.length == this.limit ) { this.ele.append( this.loadbtn ); } else { this.loadbtn.hide(); } this.offset += this.limit; } this.build = function() { $.ajax({ method:"POST", url: '/wp-admin/admin-ajax.php?action=ldl_recentposts', data: 'recId='+recId+'&limit='+this.limit+'&offset='+this.offset+'&thumbAlias='+this.thumbAlias, dataType: "json", success:$.proxy( this.apply, this ), error:$.proxy( function() { this.apply( [] ); }, this ) }); } this.init = function() { this.parentNode.append( this.ele ); this.build(); } this.loadbtn.find( "a" ).on( "click", $.proxy( this.build, this ) ); this.getEle = function() { return this.ele; } this.init(); } LD.recentArticlesUI.limit = 3; LD.recentArticlesUI.thumbAlias="thumbnail"; LD.initBookmarker = function(enabled) { if ( typeof LD.bookmarkDownloader == "object" && LD.bookmarkDownloader != null && typeof $MYTHYR.bookmarker != "undefined" ) { $MYTHYR.bookmarker.download = LD.bookmarkDownloader; } $( '#ldl-bookmarks-anchor' ).each( function() { let node = $(this); let profilePg = node.attr("ldl-profile-page"); var host = node.attr("ldl-host"); if ( typeof $MYTHYR.local.bookmarker == "undefined" ) { $MYTHYR.local.bookmarker = new $MYTHYR.bookmarker("/"+profilePg+"/@@RECID@@/@@RECNAME@@", {host:host+"/",disabled:!enabled}); } $MYTHYR.local.bookmarker.anchorTo("#ldl-bookmarks-anchor:not([anchor-disabled])"); }); }